<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" isELIgnored="false"%>
<!-- 	导入Struts 2标签库 -->
<%@taglib uri="/struts-tags" prefix="s" %>
<!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>index</title>
    <link rel="stylesheet" href="layui/css/layui.css">
</head>
<body>

<a href="toadd.action" class="layui-btn btn-success">新增</a>
<%--<h1>success !!! ${sessionScope.username} </h1>--%>
<table class="layui-hide" id="test1" lay-filter="test1"></table>


<script type="text/javascript" src="layui/layui.all.js"></script>
<script>
    layui.use(['table','form', 'layer','laydate', 'jquery'], function (table,form, layer,laydate, $) {
        var $ = layui.jquery, table = layui.table, form = layui.form;
        var tableIns = table.render({
            elem: '#test1'
            ,url:'emplist.action'
            ,toolbar: '#toolbarDemo'
            ,title: '雇员数据表'
            ,cols: [[
                {type: 'checkbox', fixed: 'left'}
                ,{field:'empno', title:'用户编号', width:120, fixed: 'left', unresize: true, sort: true,align: 'center'}
                ,{field:'ename', title:'用户名', width:120, edit: 'text',sort: true}
                ,{field:'job', title:'用户职位', width:300, edit: 'text',sort: true}
                ,{field:'mgr', title:'上级领导', width:100,sort: true}
                ,{field:'sal', title:'薪水', width:100,sort: true}
                ,{field:'comm', title:'奖金', width:100,sort: true}
                ,{field:'hiredate', title:'雇佣时间',width:400,sort: true,templet: "<div>{{layui.util.toDateString(d.hiredate, 'yyyy-MM-dd HH:mm:ss')}}</div>"}
            ]]
            ,page: true //开启分页
            ,parseData: function(res){ //将原始数据解析成 table 组件所规定的数据
                console.log(res);
                //之前ssm整合时候并没有手动转换，现在必须转换一下，
                // 后台返回的数据时字符串，先要转换为对象
                var d = $.parseJSON(res);
                return {
                    "code": d.code, //解析接口状态
                    "msg": d.msg, //解析提示文本
                    "count": d.count, //解析数据长度
                    "data": d.data //解析数据列表
                };
            }

        });
    });
</script>
</body>
</html>
